package com.fc.authentication.core.spring.config;

import com.fc.authentication.common.xss.FcFilter;
import com.fc.authentication.common.xss.XssFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.DispatcherType;

/**
 * Created by Sunny on 2018/6/21.
 */
@Configuration
public class FilterConfig {




    @Bean
    public FilterRegistrationBean xssFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setDispatcherTypes(DispatcherType.REQUEST);
        registration.setFilter(new XssFilter());
        registration.addUrlPatterns("/*");
        registration.setName("xssFilter");
        registration.setOrder(1);
        return registration;
    }
    @Bean
    public FilterRegistrationBean fcFilterRegistration()
    {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setDispatcherTypes(DispatcherType.REQUEST);
        registration.setFilter(new FcFilter());
        registration.addUrlPatterns("/*");
        registration.setName("fcFilter");
        registration.setOrder(Integer.MAX_VALUE);
        return registration;
    }
}
